﻿using System;
using System.Text;
using NazTek.Utility;
using NazTek.Archive.Control.Entity;

namespace NazTek.Archive.View
{
    /// <summary>
    /// Encapsulates archive process.
    /// </summary>
    sealed class Program
    {
        /// <summary>
        /// Initiates archive process.
        /// </summary>
        /// <param name="args">Input arguments.</param>
        private static void Main(string[] args)
        {
            ArchiveConfiguration.Instance.Notice += LogArchiveNotification;
            ArchiveConfiguration.Instance.Archive();
            Console.ReadLine();
        }

        /// <summary>
        /// Builds log message.
        /// </summary>
        private static readonly StringBuilder MessageBuilder = new StringBuilder();
        /// <summary>
        /// Writes notifications to console window.
        /// </summary>
        /// <param name="sender">Notification publisher.</param>
        /// <param name="noticeEventArgs">Notification message.</param>
        private static void LogArchiveNotification(object sender, NoticeEventArgs noticeEventArgs)
        {
            Console.WriteLine(noticeEventArgs.StampedMessage);
            MessageBuilder.AppendLine(noticeEventArgs.StampedMessage);
        }
    }
}